package com.enhe.gck.pojo;

import com.alibaba.fastjson.annotation.JSONField;
import com.enhe.gck.item.OrderHWANE16677Item;
import com.kuangkie.carbon.record.Updatable;
import com.kuangkie.carbon.record.annotation.Attribute;
import com.kuangkie.carbon.record.annotation.CarbonRecord;
import com.kuangkie.carbon.record.annotation.RecordCode;
import com.kuangkie.carbon.record.annotation.Relation;
import com.kuangkie.carbon.uid.model.UidManager;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

import static com.enhe.gck.CarbonRelationType.*;

// 订单记录
@Data
@CarbonRecord("hwane16677")
public class Order implements Updatable {
    @JSONField(name = "唯一编码")
    @RecordCode
    private Long id = UidManager.getLongUID();

    // 单号
    @JSONField(name = "单号")
    @Attribute("hwan16679")
    private String order;

    // 销售金额
    @JSONField(name = "销售金额")
    @Attribute("hwan16689")
    private Double salesAmount;

    // 8位取货码
    @JSONField(name = "8位取货码")
    @Attribute("hwan16690")
    private String pickupCode;

    // 类型
    @JSONField(name = "类型")
    @Attribute("hwan16691")
    private String type;

    // 重量
    @JSONField(name = "重量")
    @Attribute("hwan16692")
    private Double weight;

    // 袋装数
    @JSONField(name = "袋装数")
    @Attribute("hwan16693")
    private Integer bags;

    // 单袋重量
    @JSONField(name = "单袋重量")
    @Attribute("hwan16694")
    private Double singleWeight;

    // 收货类型
    @JSONField(name = "收货类型")
    @Attribute("hwan16695")
    private String collectType;

    // 是否作废
    @JSONField(name = "是否作废")
    @Attribute("hwan16763")
    private String isCancel;

    // 是否退货
    @JSONField(name = "是否退货")
    @Attribute("hwan16764")
    private String isRefund;

    // 状态
    @JSONField(name = "状态")
    @Attribute("hwan16772")
    private String state;

    // IC卡号
    @JSONField(name = "IC卡号")
    @Attribute("hwan16783")
    private String icCard;



    // 运费
    @JSONField(name = "运费")
    @Attribute("hwan16827")
    private Double fare;

//    // 是否按吨计运费
//    @JSONField(name = "是否按吨计运费")
//    @Attribute("hwan16828")
//    private String isTon;

    // 是否散户下单
    @JSONField(name = "是否散户下单")
    @Attribute("hwan16851")
    private String isRetail;

    // 是否同步
    @JSONField(name = "是否同步")
    @Attribute("hwan16876")
    private boolean isSync;

    // 命令
    @JSONField(name = "命令")
    @Attribute("hwan17902")
    private String command;

    // 订单来源
    @JSONField(name = "订单来源")
    @Attribute("hwan18024")
    private String orderSource;

    @JSONField(name="皮重")
    @Attribute("hwan18120")
    private Double weightTare;

    // 毛重
    @JSONField(name="毛重")
    @Attribute("hwan18121")
    private Double weightGross;

    // 实际重量
    @JSONField(name = "实际重量")
    @Attribute("hwan16813")
    private Double actualWeight;

    @JSONField(name = "录入类型")
    @Attribute("hwan18263")
    private String inputType;

    @JSONField(name = "过磅1重量")
    @Attribute("hwan18404")
    private Double weight1;
    @JSONField(name = "过磅2计算重量")
    @Attribute("hwan18405")
    private Double weight2;
    @JSONField(name = "过磅2实际重量")
    @Attribute("hwan20473")

    private BigDecimal weight21;
    @JSONField(name = "过磅1时间")
    @Attribute("hwan18402")
    private LocalDateTime weight1Time;
    @JSONField(name = "过磅2时间")
    @Attribute("hwan18403")
    private LocalDateTime weight2Time;

    // 是否已开票
    @JSONField(name = "是否已开票")
    @Attribute(OrderHWANE16677Item.基本属性组_是否已开票)
    private Boolean invoicedFlag;

    // 上次装货量
    @Attribute(OrderHWANE16677Item.基本属性组_上次装货量)
    private Integer lastLoadingVolume;

    // 发卡时间
    @JSONField(name = "发卡时间")
    @Attribute(OrderHWANE16677Item.基本属性组_发卡时间)
    private LocalDateTime cardIssuanceTime;

    // 收卡时间
    @JSONField(name = "收卡时间")
    @Attribute(OrderHWANE16677Item.基本属性组_收卡时间)
    private LocalDateTime cardCollectionTime;

    // 是否已打印小票
    @JSONField(name = "是否已打印小票")
    @Attribute(OrderHWANE16677Item.基本属性组_是否已打印小票)
    private Boolean receiptPrintedFlag;

    // 小票打印次数
    @JSONField(name = "小票打印次数")
    @Attribute(OrderHWANE16677Item.基本属性组_小票打印次数)
    private Integer receiptPrintedNumber;

    @JSONField(name = "完成时间")
    @Attribute("hwan19295")
    private LocalDateTime finishTime;

    @Attribute(OrderHWANE16677Item.基本属性组_实际袋装数)
    private Integer actualBags;
    @Attribute(OrderHWANE16677Item.基本属性组_补包数)
    private Integer supplementBags;

    @JSONField(name = "是否补充车号")
    @Attribute("hwan19581")
    private Boolean isSupplyCar;

    @JSONField(name = "提货单")
    @Attribute("hwan19653")
    private Boolean isGenerate;

    @JSONField(name = "二级经销商")
    @Attribute("hwan20796")
    private Boolean isTwo;

    @JSONField(name = "派车时间")
    @Attribute("hwan20872")
    private LocalDateTime dispatchTime;

    @JSONField(name = "批量")
    @Attribute("hwan20982")
    private Boolean batch;
    @JSONField(name = "生成单数")
    @Attribute("hwan20983")
    private Integer saveNumber;
    @JSONField(name = "是否相同车")
    @Attribute("hwan21079")
    private Boolean isEqual;
    @Attribute(OrderHWANE16677Item.基本属性组_装车完成标记)
    private Boolean isLoadComplete;
    @Attribute(OrderHWANE16677Item.基本属性组_异常是否通过)
    private Boolean exceptionPassOrNot;


    @JSONField(name = "备注")
    @Attribute("hwan19604")
    private String remark;

    @Relation(RR_订单记录_客户名称_客户管理)
    private Customer customer;
    @Relation(RR_订单记录_客户名称_客户管理)
    private Long customerId;

    @Relation(RR_订单记录_散户_客户管理)
    private Customer customerS;
    @Relation(RR_订单记录_散户_客户管理)
    private Long customerSId;

    @Relation(RR_订单记录_车牌号_车辆管理)
    private Car car;
    @Relation(RR_订单记录_车牌号_车辆管理)
    private Long carId;

    @Relation(RR_订单记录_产品物料_产品管理)
    private Goods goods;
    @Relation(RR_订单记录_产品物料_产品管理)
    private Long goodsId;

    @Relation(RR_订单记录_司机_司机管理)
    private Driver driver;
    @Relation(RR_订单记录_司机_司机管理)
    private Long driverId;

    @Relation(RR_订单记录_属于扣款记录_扣款记录)
    private List<Deduction> deductions;

    @Relation(RR_订单记录_销售订单的装车批次记录_装车批次记录)
    private List<LoadingBatchRecord> loadingBatchRecords;

    @Override
    public String getRecordCode() {
        return this.id == null ? null : this.id.toString();
    }
}